/********************************************************************************
*
* File: pcat.lex
* Title: The PCAT scanner
* Student names and IDs:
*
********************************************************************************/
%{
#include "Global.h"
extern int lineno;
%}
lparen "("
rparen ")"
lbracket "["
rbracket "]"
lbrace "{"
rbrace "}"
colon ":"
dot \56
semicolon ";"
comma ","
assign ":""="
plus "+"
minus "-"
star \52
slash \57
backslash \134
equal "="
neq "<"">"
lt "<"
le "<""="
gt ">"
ge ">""="
labracket "[""<"
rabracket ">""]"
quotation \42
commentstart "("\52
commentend \52")"
enter \n
integer [0-9]+
real [0-9]*\.[0-9]+
string [a-zA-Z0-9]+
%%
{lparen} {return SYMBOL_LPAREN;}
{rparen} {return SYMBOL_RPAREN;}
{lbracket} {return SYMBOL_LBRACKET;}
{rbracket} {return SYMBOL_RBRACKET;}
{lbrace} {return SYMBOL_LBRACE;}
{rbrace} {return SYMBOL_RBRACE;}
{colon} {return SYMBOL_COLON;}
{dot} {return SYMBOL_DOT;}
{semicolon} {return SYMBOL_SEMICOLON;}
{comma} {return SYMBOL_COMMA;}
{assign} {return SYMBOL_ASSIGN;}
{plus} {return SYMBOL_PLUS;}
{minus} {return SYMBOL_MINUS;}
{star} {return SYMBOL_STAR;}
{slash} {return SYMBOL_SLASH;}
{backslash} {return SYMBOL_BACKSLASH;}
{equal} {return SYMBOL_EQ;}
{neq} {return SYMBOL_NEQ;}
{lt} {return SYMBOL_LT;}
{le} {return SYMBOL_LE;}
{gt} {return SYMBOL_GT;}
{ge} {return SYMBOL_GE;}
{labracket} {return SYMBOL_LABRACKET;}
{rabracket} {return SYMBOL_RABRACKET;}
{quotation} {return SYMBOL_QUOTATION;}
{commentstart} {return SYMBOL_COMMENTSTART;}
{commentend} {return SYMBOL_COMMENTEND;}
identifier {return KEYWORD_IDENTIFIER;}
integer {return KEYWORD_INTEGER;}
real {return KEYWORD_REAL;}
string {return KEYWORD_STRING;}
PROGRAM {return KEYWORD_PROGRAM;}
IS {return KEYWORD_IS;}
BEGIN {return KEYWORD_BEGIN;}
END {return KEYWORD_END;}
VAR {return KEYWORD_VAR;}
TYPE {return KEYWORD_TYPE;}
PROCEDURE {return KEYWORD_PROCEDURE;}
ARRAY {return KEYWORD_ARRAY;}
RECORD {return KEYWORD_RECORD;}
IN {return KEYWORD_IN;}
OUT {return KEYWORD_OUT;}
READ {return KEYWORD_READ;}
WRITE {return KEYWORD_WRITE;}
IF {return KEYWORD_IF;}
THEN {return KEYWORD_THEN;}
ELSE {return KEYWORD_ELSE;}
ELSIF {return KEYWORD_ELSIF;}
WHILE {return KEYWORD_WHILE;}
DO {return KEYWORD_DO;}
LOOP {return KEYWORD_LOOP;}
FOR {return KEYWORD_FOR;}
EXIT {return KEYWORD_EXIT;}
RETURN {return KEYWORD_RETURN;}
TO {return KEYWORD_TO;}
BY {return KEYWORD_BY;}
AND {return KEYWORD_AND;}
OR {return KEYWORD_OR;}
NOT {return KEYWORD_NOT;}
OF {return KEYWORD_OF;}
DIV {return KEYWORD_DIV;}
MOD {return KEYWORD_MOD;}
INTEGER {return TYPE_INTEGER;}
REAL {return TYPE_REAL;}
STRING {return TYPE_STRING;}
{enter} {++lineno;}
{integer} {return CONST_INTEGER;}
{real} {return CONST_REAL;}
{string} {return CONST_STRING;}
%%
int yywrap()
{
    return 1;
}
